package com.qianfeng.zhangwei.blutooth.taks;

import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;

import java.io.IOException;
import java.util.UUID;

/**
 * @说 明：
 * @项目名称：Sz1504Adv
 * @包 名： com.qianfeng.zhangwei.blutooth.taks
 * @类 名： BluetoothClient
 * @创 建人： zhangwei
 * @创建时间：2015-08-11 10:40
 * @版 本：v1.0
 * @修 改人：
 * @修改时间：
 * @修改备注：
 */
public class BluetoothClientTask extends Thread {
    private BluetoothSocket mSocket;
    private UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
    private BluetoothDevice device;

    public BluetoothClientTask(BluetoothDevice device) {
        this.device = device;
        try {
            mSocket = device.createRfcommSocketToServiceRecord(uuid);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    @Override
    public void run() {
        try {
            mSocket.connect();

        } catch (IOException e) {
            try {
                mSocket.close();
            } catch (IOException e1) {
                e1.printStackTrace();
                return;
            }
        }
    }
}
